package com.winbomb.simulife;

import java.util.HashMap;

public class Ability {

	/** 智力 */
	public static final String IQ = "intelligence";
	/** 情商 */
	public static final String EQ = "emotional";
	/** 知识 */
	public static final String KNOWLEDGE = "knowledge";
	/** 运动天赋 */
	public static final String SPORTS = "sports";
	/** 表演天赋 */
	public static final String ACTING = "acting";
	/** 音乐天赋 */
	public static final String SINGING = "singing";
	/** 艺术天赋 */
	public static final String ART = "art";
	/** 政治才能 */
	public static final String POLITICAL = "political";

	/**
	 * 能力矩阵，键为能力的名称，值为能力的数值。
	 */
	private HashMap<String, Integer> abilityMap = new HashMap<String, Integer>();

	/**
	 * 获取某种能力的值，如果获取不到（该能力不存在），则返回-1。
	 * 
	 * @param key
	 * @return
	 */
	public int get(String key) {

		Integer ability = abilityMap.get(key);

		if (ability == null) {
			return -1;
		}

		return ability.intValue();
	}

	public void set(String key, int value) {
		abilityMap.put(key, new Integer(value));
	}

	public void modify(String key, int delta) {
		if (!abilityMap.containsKey(key)) {
			return;
		}

		int old = abilityMap.get(key).intValue();
		abilityMap.put(key, new Integer(old + delta));
	}

}
